import { defHttp } from '/@/utils/http/axios';

enum Api {
  overview = 'dashboard/getDashboardData',
  assertsAmount = '/dashboard/queryAssertsAmount',
  deviceStateBar = '/dashboard/getDeviceStateBarData',
  deviceStateLine = '/dashboard/getDeviceStateLineData',
  deviceStatus = '/dashboard/queryDeviceStatus',
  assetState = '/dashboard/getAssetStateLineData',
}

export interface growCardDataType {
  loading: boolean;
  totalCount?: number;
  totalPrice?: number;
  deviceOnline?: number;
  deviceOffline?: number;
}
export interface deviceStateDataType {
  loading: boolean;
  deviceStateNameList?: string[];
  deviceStateCountList?: number[];
}
export interface deviceOnlineDataType {
  loading: boolean;
  deviceTimeList?: string[];
  deviceOnlineList?: number[];
  deviceOfflineList?: number[];
}
export interface assetStateDataType {
  loading: boolean;
  useStateNameList?: string[];
  useStateCountList?: number[];
}
export const getOverviewStatistics = () => defHttp.post<{}>({ url: Api.overview });
export const queryAssertsAmount = () => defHttp.get<{ totalCount: number; totalPrice: number }>({ url: Api.assertsAmount });
export const queryDeviceStatus = () => defHttp.get<{ deviceOnline: number; deviceOffline: number }>({ url: Api.deviceStatus });
export const getAssetStateLineData = () => defHttp.get<{ onlineData: number[]; xAxis: string[] }>({ url: Api.assetState });
export const getDeviceStateBarData = () => defHttp.get<{ data: number[]; xAxis: string[] }>({ url: Api.deviceStateBar });
export const getDeviceStateLineData = () =>
  defHttp.get<{ xAxis: string[]; offlineData: number[]; onlineData: number[] }>({ url: Api.deviceStateLine });
